home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / ScrollView / MyObject.m < prev    next >
Text File  |  1995-06-12  |  6KB  |  244 lines

  1.  
  2. /*      Generated by Interface Builder 
  3. **    You may freely copy, distribute and reuse the code in this example.
  4. **    Eric Tremblay disclaims any warranty of any kind, expressed or implied, **      as to its fitness for any particular use.
  5. **      July 26, 1992 updated August 7, 1993
  6. */
  7.  
  8. #import "MyObject.h"
  9.  
  10. @implementation MyObject
  11.  
  12.  
  13. - appDidInit:sender
  14. {
  15.  
  16.         /* Set the ScrollView to accept graphics */
  17.         /* Impliment drag and drop graphics using one line! */
  18.     [[MyScrollView docView] setGraphicsImportEnabled:YES];
  19.  
  20.         SaveName = "Library/ScrollView/Test.Scrollview.rtfd";
  21.  
  22.         return self;
  23. }
  24.  
  25.  
  26. - textLengthTest:sender
  27. /* The number of characters in the Text object . */
  28. {
  29.          int HowLongIsTheText;    
  30.      
  31.      document = [MyScrollView docView];
  32.  
  33.          /* assigns the length of the text in MyScrollView */
  34.          HowLongIsTheText = [document textLength]; 
  35.  
  36.         /* Displays how many characters is in the text */
  37.         [theTextLength setIntValue:HowLongIsTheText]; 
  38.         return self;
  39. }
  40.  
  41. - selectTextTest:sender
  42. /* This selects "highlights" the text in MyScrollView */
  43. {
  44.      [[MyScrollView docView] selectText:document];
  45.  
  46.     return self;
  47.  }
  48.  
  49.  - checkSpellingTest:sender
  50.  /* This checks the spelling of the text in the MyScrollView document */
  51.  {
  52.       document = [MyScrollView docView];
  53.     [[MyScrollView docView] checkSpelling:document]; /* Spell check */
  54.     [[MyScrollView docView] showGuessPanel:document]; /* Guess and replace panel */
  55.     return self;
  56.  }
  57.  
  58. - byteLengthTest:sender
  59. /* This displays how many bytes are used in the text of MyScrollView */
  60. {
  61.        int HowManyBytes;
  62.        document = [MyScrollView docView];
  63.        HowManyBytes = [document byteLength]; 
  64.        [theByteLength setIntValue:HowManyBytes];
  65.        return self;
  66.  }
  67.  
  68.  
  69. - setTextTest:sender
  70. /* This takes the text in setTextInput and displays it in MyScrollView */
  71. {
  72.        const char *inputString;
  73.        inputString = [setTextInput stringValue];
  74.        [[MyScrollView docView] setText:inputString];
  75.        return self;
  76. }
  77.  
  78. - appendTextTest:sender
  79. /* This will get the text in appendTextInput and add it at the end of MyScrollView */
  80. {
  81.         int HowLongIsTheText;
  82.        const char *inputString;
  83.      
  84.         inputString = [appendTextInput stringValue]; /* gets the inputString */
  85.     
  86.     document = [MyScrollView docView];
  87.      
  88.     /* Determines how many characters are in MyScrollViews document */
  89.     HowLongIsTheText = [document textLength]; 
  90.       
  91.     /* Selects and empty selection, which in fact places the cursor at the end of the document */
  92.     [document setSel:HowLongIsTheText:HowLongIsTheText];
  93.         
  94.     /* Replaces the selection (in this case it is empty) with inputString */
  95.     [document replaceSel:inputString]; 
  96.  
  97.     return self;
  98. }
  99.  
  100. - backWhite:sender
  101. /* This will change the background color of MyScrollView */
  102. {
  103.        [[MyScrollView docView] setBackgroundGray:NX_WHITE];
  104.        [MyScrollView display];
  105.     return self;
  106. }
  107.  
  108.  
  109. - backBlack:sender
  110. /* This will change the background color of MyScrollView */
  111. {
  112.      [[MyScrollView docView] setBackgroundGray:NX_BLACK];
  113.        [MyScrollView display];
  114.     return self;
  115. }
  116.  
  117.  
  118. - backLgray:sender
  119. /* This will change the background color of MyScrollView */
  120. {
  121.      [[MyScrollView docView] setBackgroundGray:NX_LTGRAY];
  122.        [MyScrollView display];
  123.     return self;
  124. }
  125.  
  126.  
  127. - backDgray:sender
  128. /* This will change the background color of MyScrollView */
  129. {
  130.      [[MyScrollView docView] setBackgroundGray:NX_DKGRAY];
  131.        [MyScrollView display];
  132.     return self;
  133. }
  134.  
  135.  
  136. - textWhite:sender
  137. /* changes the color of the text in MyScrollView */
  138. {
  139.          [[MyScrollView docView] setTextGray:NX_WHITE];
  140.          [MyScrollView display];
  141.          return self;
  142.  }
  143.  
  144. - textBlack:sender
  145. /* changes the color of the text in MyScrollView */
  146. {
  147.          [[MyScrollView docView] setTextGray:NX_BLACK];
  148.          [MyScrollView display];
  149.          return self;
  150.  }
  151.  
  152. - textLgray:sender
  153. /* changes the color of the text in MyScrollView */
  154. {
  155.          [[MyScrollView docView] setTextGray:NX_LTGRAY];
  156.          [MyScrollView display];
  157.          return self;
  158.  }
  159.  
  160. - textDgray:sender
  161. /* changes the color of the text in MyScrollView */
  162. {
  163.          [[MyScrollView docView] setTextGray:NX_DKGRAY];
  164.          [MyScrollView display];
  165.          return self;
  166.  }
  167.  
  168. - PrintScroll:sender
  169. /* This method will print the scrollView to the printer */
  170. // Printing is rather simple; just send printPSCode: to the text view
  171. // you wish to print. The print panel will automatically pop up and unless
  172. // the user cancels the printout the text view will be printed.
  173. {
  174.   
  175.     [[MyScrollView docView] printPSCode:self];
  176.     return self;
  177.  }
  178.  
  179. - PrintWindow:sender
  180. /* This method will print the WHOLE panel to the printer */
  181.  
  182. {
  183.   
  184.     [TheWindow printPSCode:self];
  185.     return self;
  186.  }
  187.  
  188. - Ruler:sender
  189. /* This method toggles a rular in the scrollview */
  190. {
  191.     [[MyScrollView docView] toggleRuler:self];
  192.     return self;
  193. }
  194.  
  195. - Left:sender
  196. /* This will justify the text to the left */
  197. {
  198.  
  199.     [[MyScrollView docView] setAlignment:NX_LEFTALIGNED];
  200.     [MyScrollView display];
  201.     return self;
  202. }
  203.  
  204. - Right:sender
  205. /* This will justify the text to the right */
  206. {
  207.  
  208.     [[MyScrollView docView] setAlignment:NX_RIGHTALIGNED];
  209.     [MyScrollView display];
  210.     return self;
  211. }
  212.  
  213. - Center:sender
  214. /* This will justify the text to the Centered */
  215. {
  216.  
  217.     [[MyScrollView docView] setAlignment:NX_CENTERED];
  218.     [MyScrollView display];
  219.     return self;
  220. }
  221.  
  222. - Save:sender
  223. {
  224.     
  225.     error = [[MyScrollView docView]  saveRTFDTo:SaveName
  226.            removeBackup:YES
  227.            errorHandler:self];
  228.            
  229.     return self;
  230.     
  231. }
  232.  
  233.  
  234. - Load:sender
  235. {
  236.  
  237.     error = [[MyScrollView docView]  openRTFDFrom:SaveName];
  238.     
  239.         return self;
  240. }
  241.  
  242.  
  243. @end
  244.